﻿using NHibernate;
using TestBat.IModels.Services;
using TestBat.Models.Attributes;

namespace TestBat.Models.Services
{
    public class UnsavedChangesService : IUnsavedChangesService
    {
        public UnsavedChangesService(ISessionFactory sessionFactory)
        {
            this.sessionFactory = sessionFactory;
        }

        [Conversation]
        public bool UnsavedChanges()
        {
            ISession session = sessionFactory.GetCurrentSession();
            bool dirty = session.IsDirty();
            return dirty;
        }

        private ISessionFactory sessionFactory;
    }
}
